import { createI18n } from "vue-i18n";
import { useAppStoreHook } from "@/store/modules/app";
//引入本地语言包
import enLocale from "./package/en";
import zhCnLocale from "./package/zh-cn";

const appStore = useAppStoreHook();

const messages = {
  "zh-cn": {
    ...zhCnLocale,
  },
  en: {
    ...enLocale,
  },
};

const i18n = createI18n({
  legacy: false, //是否使用旧版本的i18n API
  locale: appStore.language, //表示当前的语言环境
  messages: messages, //本地化字典
  globalInjection: true, //将i18n注入到全局上下文中，不用手动传递
});

export default i18n;
